<%
=begin
apps: postgresql-ha, postgresql
platforms: kubernetes, tanzu-application-catalog
id: use_global_variables
title: Use of global variables
category: configuration
weight: 50
=end %>

In more complex scenarios, we may have the following tree of dependencies:

<%= documentation_img '/images/img/platforms/kubernetes/charts/postgresql-ha/postgresql-ha-global-variables.png', 'PostgreSQL HA Global variables' %>

The three charts below depend on the parent chart Chart 1. However, subcharts 1 and 2 may need to connect to PostgreSQL HA as well. In order to do so, subcharts 1 and 2 need to know the PostgreSQL HA credentials, so one option for deploying could be deploy Chart 1 with the following parameters:

~~~
postgresql.postgresqlPassword=testtest
subchart1.postgresql.postgresqlPassword=testtest
subchart2.postgresql.postgresqlPassword=testtest
postgresql.postgresqlDatabase=db1
subchart1.postgresql.postgresqlDatabase=db1
subchart2.postgresql.postgresqlDatabase=db1
~~~

If the number of dependent sub-charts increases, installing the chart with parameters can become increasingly difficult. An alternative would be to set the credentials using global variables as follows:

~~~
global.postgresql.postgresqlPassword=testtest
global.postgresql.postgresqlDatabase=db1
~~~

This way, the credentials will be available in all of the subcharts.
